<template>
  <div v-if="visible" class="modal-overlay" @click="closeModal">
    <div class="login-container" @click.stop>
      <div class="login-header">
        <h2>欢迎您，进入系统</h2>
        <div class="divider"></div>
        <div class="location-icon">
          <div class="pin-icon">
            <div class="pin-dot"></div>
          </div>
        </div>
      </div>
      
      <div class="login-form">
        <div class="input-group">
          <input 
            type="text" 
            placeholder="用户名" 
            class="login-input" 
            v-model="username"
          />
        </div>
        <div class="input-group">
          <input 
            type="password" 
            placeholder="密码" 
            class="login-input" 
            v-model="password"
          />
        </div>
        
        <button class="login-button" @click="handleLogin">
          登录系统
        </button>
      </div>
      
      <div class="login-footer">
        <a href="#" class="forgot-password">忘记密码？</a>
        <a href="#" class="register-link">新用户？注册</a>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

// Props
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  }
});

// Emits
const emit = defineEmits(['close', 'login']);

// Reactive data
const username = ref('');
const password = ref('');

// Methods
const closeModal = () => {
  emit('close');
};

const handleLogin = () => {
  // 在实际应用中，这里会有表单验证和登录逻辑
  emit('login', { username: username.value, password: password.value });
};
</script>

<style scoped>
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-container {
  width: 350px;
  background-color: #FFD700;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.login-header h2 {
  color: #fff;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.divider {
  width: 50px;
  height: 2px;
  background-color: #fff;
  margin: 0 auto 1.5rem;
}

.location-icon {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 2rem;
}

.pin-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 60px;
  background-color: #FF6B6B;
  border-radius: 20px 20px 0 0;
  position: relative;
}

.pin-icon::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 15px;
  background-color: #FF6B6B;
}

.pin-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background-color: #fff;
  border-radius: 50%;
}

.login-form {
  margin-bottom: 1.5rem;
}

.input-group {
  margin-bottom: 1rem;
}

.login-input {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}

.login-button {
  width: 100%;
  padding: 0.75rem;
  background-color: #FF9500;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s;
}

.login-button:hover {
  background-color: #FF8A00;
}

.login-footer {
  display: flex;
  justify-content: space-between;
}

.forgot-password, .register-link {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}

.forgot-password:hover, .register-link:hover {
  text-decoration: underline;
}
</style>